load("//python/config_settings:transition.bzl", "py_binary")
load("//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
load("//tools/private:publish_deps.bzl", "publish_deps")

py_console_script_binary(
    name = "twine",
    # We use a py_binary rule with version transitions to ensure that we do not
    # rely on the default version of the registered python toolchain. What is more
    # we are using this instead of `@python_versions//3.11:defs.bzl` because loading
    # that file relies on bzlmod being enabled.
    binary_rule = py_binary,
    pkg = "@rules_python_publish_deps//twine",
    python_version = "3.11",
    script = "twine",
    visibility = ["//visibility:public"],
)

filegroup(
    name = "distribution",
    srcs = [
        "BUILD.bazel",
        "requirements.txt",
        "requirements_darwin.txt",
        "requirements_linux.txt",
        "requirements_universal.txt",
        "requirements_windows.txt",
    ],
    visibility = ["//tools:__subpackages__"],
)

# Run bazel run //private:requirements.update to update the outs
publish_deps(
    name = "requirements",
    srcs = ["requirements.in"],
    outs = {
        "requirements.txt": "linux",  # TODO: maybe deprecate
        "requirements_darwin.txt": "macos",
        "requirements_linux.txt": "linux",
        "requirements_universal.txt": "",  # universal
        "requirements_windows.txt": "windows",
    },
    upgrade = True,
    visibility = ["//private:__pkg__"],
)
